﻿using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Basefr.Attributes;
using Basefr.Core.Entities;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Paas.Core.Approvals.Entities
{
    /// <summary>
    /// 审批流程模板节点
    /// </summary>
    [MainTable(nameof(ApproveTemplateStep))]
    public class ApproveTemplateStep : EntityBase, ISortable
    {
        /// <summary>
        /// 模板
        /// </summary>
        public int TemplateId { get; set; }
        [ForeignKey(nameof(TemplateId))]
        public virtual ApproveTemplate Template { get; set; }

        /// <summary>
        /// 节点名称
        /// </summary>
        [Required]
        [MaxLength(100)]
        public string Name { get; set; }

        /// <summary>
        /// 顺序
        /// </summary>
        public int SortIndex { get; set; }

        /// <summary>
        /// 只有流程发起者才有权执行
        /// </summary>
        public bool OperateByInitiator { get; set; }

        /// <summary>
        /// 改变对象状态（按顺序，到下一个状态）
        /// </summary>
        public bool ChangeObjectState { get; set; }

        /// <summary>
        /// 下一步节点
        /// </summary>
        public int? NextId { get; set; }
        [ForeignKey(nameof(NextId))]
        public virtual ApproveTemplateStep Next { get; set; }

        /// <summary>
        /// 执行人
        /// </summary>
        public virtual List<ApproveTemplateStepOperator> Operators { get; set; }

    }
}

